<?php
class Login_Check_Action extends NICED_Action 
{       
	public function execute() 
	{
		$controller = $this->getController();
		$request    = $controller->getRequest();			

		try
		{
            $this->checkLogin($controller);
		}
		catch (Exception $e)
		{
			$controller->handleException(new NICED_Exception($e->getMessage()));
			return self::SUCCESS;
		}

		return self::SUCCESS;
	}

    public static function checkLogin($controller)
    {
        //is login frontend
		$model      = $controller->getModel('Login.Index');
		$request    = $controller->getRequest();			
        $bool = $model->isLogin();

        if (!$bool)
        {
            $request->set("call_back_url", "/index");
            //NICED_Application::forward("Login.Index");
            header("Location: /login");
            exit;
        }
    }

}//end class
